package com.example.redisspringbootautoconfigure.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import redis.clients.jedis.Jedis;

@Configuration
@ConditionalOnClass(value = {Jedis.class})
@Import({RedisProperties.class})
public class RedisAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(value = {Jedis.class})
    public Jedis jedis(RedisProperties redisProperties) {
        System.out.println("创建了redis了" + redisProperties);
        return new Jedis(redisProperties.getHost(), redisProperties.getPort());
    }

}